
local hunshang = fk.CreateSkill{
  name = "lvshi__hunshang",
  tags = { Skill.Lord }
}

Fk:loadTranslationTable{
  ["lvshi__hunshang"] = "魂殇",
  [":lvshi__hunshang"] = "主公技，每轮限X次，当你进入濒死状态时，你可发动一次“英魂”。（X为轮次开始时吴势力角色的数量）",
  ["@lvshi__hunshang-round"] = "魂殇",
  ["#lvshi__hunshang"] = "魂殇：你可发动一次“英魂”",

  ["$lvshi__hunshang"] = "壮士不死则已，死，必扬名！",
}

hunshang:addEffect(fk.EnterDying, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(hunshang.name) and target == player and
    player:usedSkillTimes(hunshang.name, Player.HistoryRound) < player:getMark("@lvshi__hunshang-round")
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {skill_name = hunshang.name, prompt = "#lvshi__hunshang"})
  end,
  on_use = function(self, event, target, player, data)
    local yinghun = Fk.skills["lvshi__yinghun"]
    yinghun:doCost(event, target, player, data)
  end,
})

hunshang:addEffect(fk.RoundStart, {
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(hunshang.name)
  end,
  on_refresh = function(self, event, target, player, data)
    local n = #table.filter(player.room:getAlivePlayers(true), function (p)
      return p.kingdom == "wu"
    end)
    player.room:setPlayerMark(player, "@lvshi__hunshang-round", n)
  end,
})


return hunshang